#!/usr/bin/env bash

requirements_void_lib_installed()
{
  xbps-query -l | __rvm_grep "ii $1-[0-9]" >/dev/null || return $?
}

requirements_void_libs_install()
{
  __rvm_try_sudo xbps-install -S "$@" || return $?
}

requirements_void_libs_remove()
{
  __rvm_try_sudo xbps-remove -R "$@" || return $?
}

requirements_void_define_base()
{
  requirements_check "$@" \
    autoconf automake bison ca-certificates curl \
    gdbm-devel glibc-devel gmp-devel \
    libffi-devel openssl-devel libtool libyaml-devel \
    make ncurses-devel \
    patch pkg-config readline-devel \
    sqlite-devel zlib-devel

   # libc6-dev > glibc-devel ?
   # libgdbm-dev > gdbm-devel
   # libncurses5-dev > ncurses-devel
   # libreadline-dev > readline-devel
   # libgmp-dev > gmp-devel
   # libssl-dev > libssl45 ???
   # libsqlite3-dev > sqlite-devel
   # libyaml-dev > libyaml-devel
   # sqlite3 > sqlite
   # zlib1g > zlib
   # zlib1g-dev > zlib-devel

   # check https://www.reddit.com/r/voidlinux/comments/9i42l1/installing_asdf_version_manager_with_openssl/
}

requirements_void_define()
{
  # https://voidlinux.org/packages/

  if [[ "$1" == *head ]]
  then
      requirements_check git
  fi

  case "$1" in
    (rvm)
      requirements_check bash curl patch bzip2 gawk
      ;;

    (jruby*)
      # Not implemented
      true
      ;;

    (ir*)
      # Not implemented
      true
      ;;

    (opal)
      # Not implemented
      true
      ;;

    (rbx*|rubinius*)
      # Not implemented
      true
      ;;

    (truffleruby*)
      # Not implemented
      true
      ;;

    (*)
      requirements_void_define_base gcc
      ;;
  esac
}
